package me.zingon.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.client.RestTemplate;

import com.alibaba.fastjson.JSON;

import me.zingon.service.PackageService;
import org.springframework.web.util.HtmlUtils;

@Controller
@RequestMapping("/package")
public class PackageController {
	
	@Autowired
	PackageService packageService;
	
	
	@RequestMapping("/getPackages.ztc")
	@ResponseBody
	public Object getPackages(){
		return  packageService.getPackages();
	}
	
	@RequestMapping("/addPackage.ztc")
	@ResponseBody
	public Object addPackage(@RequestParam("ownerPhone")String ownerPhone,
							 @RequestParam("packageType")String packageType,
							 @RequestParam("packageCode")String packageCode){
		return packageService.addPackage(ownerPhone,packageType,packageCode,1); 
	}
	
	@RequestMapping("/advice.ztc")
	@ResponseBody
	public void advice(@RequestParam("email")String to,
						 @RequestParam("pId")int pId,
						 @RequestParam("packageType")String packageType,
						 @RequestParam("packageCode")String packageCode){  
		packageService.advice(to, "您的【"+packageType+"】包裹，到了,\n\r单号【"+packageCode+"】", pId);
	}
	
	@RequestMapping("/filePackage.ztc")
	@ResponseBody
	public void filePackage(@RequestParam("id")int id){  
		packageService.filePackage(id);
	}
}
